package com.fp.m7.model;

import java.util.Set;

import org.neo4j.graphdb.Direction;
import org.springframework.data.neo4j.annotation.Fetch;
import org.springframework.data.neo4j.annotation.Indexed;
import org.springframework.data.neo4j.annotation.NodeEntity;
import org.springframework.data.neo4j.annotation.RelatedTo;
import org.springframework.data.neo4j.annotation.RelatedToVia;

@NodeEntity
public class Account extends EntityBase implements com.fp.m7.api.model.Account {
	private static final long serialVersionUID = -2850059047398024586L;

	@Indexed(unique = true)
	private String username;
	private String password;

	private String description;
	private String status;

	private boolean disabled;

	@Indexed
	private String nickname;
	private String avatarUrl;

	@RelatedTo(type = "POSTS", elementClass = Comment.class)
	private Set<Comment> comments;

	@RelatedTo(type = "FOLLOWS", direction = Direction.INCOMING)
	private Account followedBy; // TODO necessary?

	@RelatedTo(type = "FOLLOWS", elementClass = Account.class)
	private Set<Account> following;

	@Fetch
	@RelatedToVia(type = "FOLLOWS", elementClass = Follow.class)
	private Set<Follow> follows;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public boolean isDisabled() {
		return disabled;
	}

	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getAvatarUrl() {
		return avatarUrl;
	}

	public void setAvatarUrl(String avatarUrl) {
		this.avatarUrl = avatarUrl;
	}

	public Set<Comment> getComments() {
		return comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}

	public Set<Account> getFollowing() {
		return following;
	}

	public void setFollowing(Set<Account> following) {
		this.following = following;
	}
	
	public Account getFollowedBy() {
		return followedBy;
	}
	
	public void setFollowedBy(Account followedBy) {
		this.followedBy = followedBy;
	}

	public Set<Follow> getFollows() {
		return follows;
	}

	public void setFollows(Set<Follow> follows) {
		this.follows = follows;
	}

	@Override
	public String toString() {
		return new StringBuilder("Account [id=").append(id) //
				.append("; username=").append(username) //
				.append("; nickname=").append(nickname) //
				.append("; url=").append(avatarUrl) //
				.append("; auditCD=").append(auditCD) //
				.append("]").toString();
	}
}
